<template>
  <div>
    <router-link tag="div" class="book-box" :to="{path: '/bookDetail', query:{pid: item.id, agentId: agentId}}" v-for="item in bookList" :key="item.id" v-if="bookList.length>0">
        <!-- <img src="../../../assets/img/book-photo.png" alt=""> -->
        <img :src="item.coverImg" alt="">
        <div class="book-intro">
            <h3>{{item.title}}| {{item.unscramble}}</h3>
            <p style="-webkit-box-orient:vertical">{{item.summary}}</p>
            <span class="book-more">详情</span>
        </div>
    </router-link>
     <div class="no-circle-box" v-if="bookList.length < 1">
            <img src="../../../assets/img/no-data-show.png" alt="">
            <p>暂无数据</p>
     </div>
    </div>
</template>
<script>
import {Toast} from 'mint-ui'
export default {
    props:{
        bookList: Array
    },
    data () {
        return {
            agentId: JSON.parse(localStorage.getItem('dongHang_data')).agentId
        }
    },
    methods: {
      AutoSize(Img, maxWidth, maxHeight) {
        var image = new Image();
        //原图片原始地址（用于获取原图片的真实宽高，当<img>标签指定了宽、高时不受影响）
        image.src = Img.src;
        // 当图片比图片框小时不做任何改变
        if (image.width < maxWidth&& image.height < maxHeight) {
          Img.width = image.width;
          Img.height = image.height;
        } else {
          if (maxWidth/ maxHeight  <= image.width / image.height) //原图片宽高比例 大于 图片框宽高比例
          {
            Img.width = maxWidth;   //以框的宽度为标准
            Img.height = maxWidth* (image.height / image.width);
          }
          else {   //原图片宽高比例 小于 图片框宽高比例
            Img.width = maxHeight  * (image.width / image.height);
            Img.height = maxHeight  ;   //以框的高度为标准
          }
        }
      }
    },
    mounted() {
    }
}
</script>

<style lang="less" scoped>
    .book-box {
        padding: 0.3rem;
        overflow: auto;
        border-bottom: 1px solid #ccc;  
        img {
            float: left;
            width: 1.8rem;
            border-radius: 2px;
            /*height: 2.4rem;*/
        }
        .book-intro {
            margin-left: 2.1rem;
            h3 {
                margin: 0.2rem 0;
                font-size: 0.32rem;
                color: #0a0a0a;
            }
            p {
                color: #707070;
                font-size: 0.28rem;
                overflow: hidden;
                -webkit-line-clamp: 2;
                text-overflow: ellipsis;
                display: -webkit-box;
                // -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;
                overflow: hidden;
            }
            .book-more {
                color: #282828;
                font-size: 0.28rem;
                float: right;
                margin-top: 0.4rem;
                &::after {
                    content: '';
                    display: inline-block;
                    width: 0.12rem;
                    height: 0.2rem;
                    background: url(../../../assets/img/next-icon.png) no-repeat;
                    background-size: 100%;
                    margin-left: 0.15rem;
                }
            }
        }
    }
    .no-circle-box {
        text-align: center;
        font-size: 0;
        img {
            width: 3.43rem;
            margin-top: 1.2rem;
        }
        p {
            color: #282828;
            font-size: 0.3rem;
            margin-top: 0.7rem;
        }
    }
</style>
